package com.xk.timesignature.exception;

import com.xk.timesignature.enums.StatusCodeEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import static com.xk.timesignature.enums.StatusCodeEnum.FAIL;

/**
 * 业务异常
 *
 * @author 空白
 * @date 2022/01/07
 */
@Getter
@AllArgsConstructor
public class ServiceException extends RuntimeException{

    /**
     * 错误码
     */
    private Integer code = FAIL.getCode();

    /**
     * 错误信息
     */
    private final String message;

    public ServiceException(String message) {
        this.message = message;
    }

    public ServiceException(StatusCodeEnum statusCodeEnum) {
        this.code = statusCodeEnum.getCode();
        this.message = statusCodeEnum.getDesc();
    }
}
